﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using RxxAdmin.Common.Hubs;

namespace RxxAdmin.Extensions.ServiceExtensions;

public static class SignalRSetup
{
    public static void AddSignalRSetup(this IServiceCollection services)
    {
        if (services == null) throw new ArgumentNullException(nameof(services));
        services.AddSignalR().AddNewtonsoftJsonProtocol();
    }
    public static void UseSignalRMiddleware(this IApplicationBuilder app)
    {
        if (app == null) throw new ArgumentNullException(nameof(app));

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHub<ChatHubb>("/signalr/chatHub");
            //endpoints.MapHub<ChatHub>("/signalr/chatHub");
        });
    }
}
